package com.sun.generic;

/**
 * @Author: sn
 * @Desc 泛型测试
 * @Date: 2021/7/30
 */
//类泛型
public class MyGeneric<E,F> {

    //属性泛型
    private E name;
    private F age;

    public MyGeneric(E name, F age) {
        this.name = name;
        this.age = age;
    }

    //普通方法泛型
    public E getName(E name){
        System.out.println(name==this.name);
        return name;
    }

    public <T> void getAddr(T addr){
        System.out.println(addr);
    }

    //静态方法泛型
    public static <W> W  getCompany(W company){
        System.out.println(company.getClass());
        return company;
    }

    public static void main(String[] args) {
        MyGeneric.getCompany("123123");
        MyGeneric<String,Integer> g = new MyGeneric<String,Integer>("张三",12);
        g.getName("张三");
        g.getAddr(12);
    }
}
